﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using main;

namespace view
{

    public enum BTNTYPE
    {
        _NUM,
        _OP,
        _FUNC,
        _INPUT
    }
    public class btnBase : MonoBehaviour
    {

        public BTNTYPE btnType = BTNTYPE._OP;
        public string btnProp;
        public string btn_name;
        public bool isTwoNum = true;

        public Text thisText;

        void Start()
        {
            this.name = btn_name;
            if(this.btnType != BTNTYPE._INPUT)
            {
                thisText = this.transform.Find("Text").gameObject.GetComponent<Text>();
                thisText.text = btnProp;
            }
            
            


            this.gameObject.GetComponent<Button>().onClick.AddListener(delegate ()
            {
                if (this.btnType == BTNTYPE._OP)
                {
                    MaskCreate.createMask(isTwoNum, this.btnProp);
                    

                }

                if (this.btnType == BTNTYPE._NUM)
                {
                    MaskCreate.addNum(this.btnProp);
                }
                if(this.btnType == BTNTYPE._INPUT)
                {
                    MaskCreate.chooseText(this.btnProp);
                }
                if (this.btnType == BTNTYPE._FUNC)
                {
                    //if(this.btnProp == "back")
                    //{

                    //}
                    switch (this.btnProp)
                    {
                        case "back": MaskCreate.reBackToOperation(); break;
                        case "clear": MaskCreate.clearNum(); break;
                        case "tuige": MaskCreate.backNum(); break;
                        case "=": MaskCreate.compute(); break;
                    }
                }
            });

           
            

            
        }




    }

}